//Taking input through scanner
Scanner sc = new Scanner (System.in);
System.out.println("Enter the number ");
int input = sc.nextInt();
How do we check for an integer user input in java
1801
07-Oct-2015
Hi Everyone, i am working on a java application, in which i took integer input from the user. If the user enter an integer than it is working fine, but in case he inputs a digit or any decimal number , the application throws an exception. So i want to implement a validation for user input, so that only integer values will be accepted. I need a way to check whether the input values is integer type or not, here is a part of my code :
Updated on 07-Oct-2015
Anonymous User
07-Oct-2015